layui.use(['common','layer','table','form','upload'],function(){
	var $ = layui.$,
    	layer = layui.layer,
    	form = layui.form,
    	common = layui.common,
    	table = layui.table,
    	upload = layui.upload;
	
	
	var id = GetQueryString("id");
	$.post("/systemsetup/permissionsmanage/user/selectAdminUserById",{id:id},function(result){
		$("#userId").val(result.data["userId"]);
		$("#username").val(result.data["username"]);
		$("#realname").val(result.data["realname"]);
		$("#pictureSrc").attr('src',result.data["avatar"]); 
		$("#avatar").val(result.data["phone"]);
		$("#phone").val(result.data["phone"]);
		$("#email").val(result.data["email"]);
		$("input[name='sex'][value="+result.data["sex"]+"]").prop("checked", true);
	    form.render('radio');
	});
	
	 //监听提交
    form.on('submit(userEdit)', function(data){
    	 $.post("/systemsetup/permissionsmanage/user/updataAdminUser",data.field,function(result){
  		   if (result.status == 200) {
  			   parent.layer.closeAll();
  		   } else {
  			   layer.msg(result.msg);
  		   } 
  	   });
	   
	   return false;
    });
    
    upload.render({
    	  elem: '#picture',
    	  url: '/layuiUpload', //必填项
    	  method: 'post',  //可选项。HTTP类型，默认post
    	  accept:'images',
    	  done: function(res, index, upload){
    		console.log();
    		  
    		$("#avatar").val(res.data["fullPath"]);
    		$("#pictureSrc").attr('src',res.data["fullPath"]); 
    	  }
    	});
	
});